#ifndef VNavTreeView_H
#define VNavTreeView_H					 

#include "VAction.h"
#include "VNavItem.h"

///////////////////////////////////////////////////////////////////////////////

class VNavTreeView : public QTreeView
{
	Q_OBJECT
	
public:
	enum EAction
	{
		EAction_addChild,
		EAction_addBefore,
		EAction_addAfter,
		EAction_del
	};
	typedef QHash<EAction,QAction*> VActions;

public:
	VNavTreeView(QWidget *parent = NULL);
	~VNavTreeView();

	VNavItemModel *model() const;
	VNavSelectionModel *selectionModel() const;

	VActions actions() const { return m_actions;}
	//QToolBar *toolBar() const { return m_toolBar;}

public slots:
	void updateActions();
	void execAction(QAction *action);
	
private slots:
	void slot_customContextMenuRequested(const QPoint &pos);
	void slot_collapsed(const QModelIndex &index);
	void slot_expanded (const QModelIndex &index);	

protected: //	QTreeView
	virtual void focusInEvent(QFocusEvent *event);
	virtual void focusOutEvent(QFocusEvent *event);
	virtual void currentChanged(const QModelIndex &current,const QModelIndex &previous);
	virtual void drawRow(QPainter *painter,const QStyleOptionViewItem &options,const QModelIndex &index) const;
	
	class VEvent : public QEvent
	{
	public:
		VEvent(const QModelIndex &index) : QEvent(QEvent::User),m_index(index) {}
		~VEvent() {}	
		
		QModelIndex index() const { return m_index;}
		
		QModelIndex m_index;
	};
	void customEvent(QEvent *event);
	
private:
	void collapsAll(const QModelIndex &index);
	void addAction(EAction eAction,VAction *action);
	
	VActions m_actions;
	//QToolBar *m_toolBar;
	QIcon m_folderIcon;
};

///////////////////////////////////////////////////////////////////////////////

#endif
